{% extends  'templates/base.html' %}

{% block page_main %}
    {% if edit_id %}
        <h2 class="sub-header">修改生产信息</h2>
    {% else %}
        <h2 class="sub-header">添加生产信息</h2>
    {% endif %}
    <form action="" method="post" novalidate>
        {% csrf_token %}
        {% for field in form_obj %}
            <div class="form-group {% if field.errors.0 %}has-error {% endif %}">
                <label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
                {{ field }}
                <span class="help-block">{{ field.errors.0 }}</span>
            </div>
        {% endfor %}
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input type="submit" class="btn btn-success">
            </div>

        </div>

    </form>
{% endblock %}

{% block js %}
    <script>
    //机种名不能修改设置
    var $skuEle = $('#id_plan_pro_code')
    {#var $val1 = $skuEle.val()#}
    {#console.log($val1)#}
    $skuEle.attr('readonly','ture')
    $skuEle.attr('onfocus','this.defaultIndex=this.selectedIndex;')
    $skuEle.attr('onchange','this.selectedIndex=this.defaultIndex;')

    //计划id不能修改设置
    var $planEle = $('#id_sku')
    $planEle.attr('readonly','ture')
    $planEle.attr('onfocus','this.defaultIndex=this.selectedIndex;')
    $planEle.attr('onchange','this.selectedIndex=this.defaultIndex;')

    //订单id不能修改设置
    var $orderEle = $('#id_Lot')
    $orderEle.attr('readonly','ture')
    $orderEle.attr('onfocus','this.defaultIndex=this.selectedIndex;')
    $orderEle.attr('onchange','this.selectedIndex=this.defaultIndex;')

    </script>


{% endblock %}

{#{% block js %}#}
{##}
{#    <script>#}
{#    $(document).ready(function (){#}
{#        $('#id_customer').on('change',function (){#}
{#            // 获取到选中的校区id#}
{#            var customer_id = $(this).val();#}
{#            // 发送ajax请求到后端取出当前校区下面的所有课程#}
{#            $.ajax({#}
{#                url:'/plan/ajax_customer/',#}
{#                type:'get',#}
{#                data:{#}
{#                    'customer_id':customer_id#}
{#                },#}
{#                //请求成功接受结果#}
{#                success:function (res){#}
{#                    console.log(res);#}
{#                    // 找到id_sku 这个标签  机种选择的输入框#}
{#                    var $classSelect = $('#id_sku');#}
{#                    // 给原来的数据置空，删除以前的数据#}
{#                    $classSelect.text('');#}
{#                    //添加 默认的 optione html代码  <option value="">-------</option>#}
{#                    $classSelect.append('<option value="">-------</option>');#}
{#                    //循环后端返回的数据#}
{#                    $.each(res.data,function (k,v){#}
{#                        console.log(k,v);#}
{#                        //声明option标签#}
{#                        var opEle = document.createElement('option');#}
{#                        // 给后端返回的数据添加到标签中#}
{#                        $(opEle).text(v.name).attr('value',v.id)#}
{#                        //数据添加到选课框中#}
{#                        $classSelect.append(opEle)#}
{##}
{#                    })#}
{#                }#}
{#            })#}
{#        })#}
{#    })#}
{#    </script>#}
{##}
{#{% endblock %}#}